package com.yawn;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author Created by yawn on 2017-12-09 15:21
 */
public class TestDeployAndQuery {

    public static void main(String[] args) throws IOException {
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = engine.getRepositoryService();
        // 部署
        DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addClasspathResource("test.txt");
        Deployment deployment = deploymentBuilder.deploy();
        // 查询
        InputStream inputStream = repositoryService.getResourceAsStream(deployment.getId(), "test.txt");
        int count = inputStream.available();
        byte[] bytes = new byte[count];
        inputStream.read(bytes);

        System.out.println(new String(bytes));

        engine.close();
    }
}
